<?php

if (!defined('BASEPATH'))
	exit('No direct script access allowed');

class Coa_cabang_model extends CI_Model {

	function __construct() {
		parent::__construct();
	}

	function get_cabang() {
		return $this->db->get('TbMDCabang')->result_array();
	}

	function get_all() {
		return $this->db->get('TblCOACabang')->result_array();
	}

	function get_one($id) {
		$query = $this->db->get_where('TblCOACabang', array('id' => $id));
		if ($query->num_rows() > 0) {
			return $query->row_array();
		} else {
			return FALSE;
		}
	}

	function get_cabang_one($kode_cabang) {
		$query = $this->db->get_where('TbMDCabang', array('Kode' => $kode_cabang));
		if ($query->num_rows() > 0) {
			return $query->row_array();
		} else {
			return FALSE;
		}
	}

	function insert_new($data) {
		$this->db->insert('TblCOACabang', $data);
	}

	function update_old($id, $data) {
		$this->db->where('id', $id);
		$this->db->update('TblCOACabang', $data);
	}

	function delete_old($id) {
		$this->db->delete('TblCOACabang', array('id' => $id));
	}

}

/** End of file */